<?php

namespace App\Services\Payment\ESBalance;

use App\Services\Java\ApiService;
use D1M\Common\Exceptions\BusinessException;
use D1M\Payment\ESBalance\ClientInterface;
use D1M\Payment\ESBalance\OperationInterface;
use Exception;
use Illuminate\Http\Client\RequestException;

class Client implements ClientInterface
{

    private ApiService $esService;

    /**
     * @param ApiService $esService
     */
    public function __construct(ApiService $esService)
    {
        $this->esService = $esService;
    }

    /**
     * @inheritDoc
     */
    public function request(OperationInterface $operation)
    {
        return $this->esService->requestJava(
            $operation->getEndpoint(),
            $operation->getRequestBody(),
            'post'
        );
    }
}